#!/usr/bin/python3.8.9
# -*- coding: utf-8 -*-

# @Author  : Tina Yu
# @Time    : 2021-9-6 14:51

from review.service.apis.base_api import BaseApi


class WeWork(BaseApi):
    access_token: str = None

    def get_access_token(self):
        """获取access_token"""
        corp_id = 'wwbfc58d1d1813b4c7'
        corpsecret_id = 'ybaS_3F08FafycoPs7s0VoYqMZH7yyefvfw1RdmJwkE'
        gettoken_url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken"
        # r = requests.get(
        #     gettoken_url,
        #     params={
        #         "corpid": corp_id,
        #         "corpsecret": corpsecret_id
        #     }
        # )
        data = {
            'method': "get",
            'url': gettoken_url,
            'params': {
                "corpid": corp_id,
                "corpsecret": corpsecret_id
            },
        }
        r = self.request(data)
        # 封装到底层
        # print(json.dumps(r.json(), indent=4, ensure_ascii=False))
        assert r.json()["errcode"] == 0
        self.access_token = r.json()["access_token"]
